<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="/css/common.css" />
		<link rel="stylesheet" type="text/css" href="/bootstrap-3.3.7/css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="/css/flatpickr.min.css" />
		<link rel="stylesheet" type="text/css" href="/css/font-awesome.css"/>
		<link rel="stylesheet" type="text/css" href="/dialog/css/dialog.css"/>
		<link rel="stylesheet" href="/css/shoufengqin.css">
		<link rel="stylesheet" type="text/css" href="/css/haha.css" media="screen" />


		<script src="/js/jquery-1.9.1.min.js" type="text/javascript" ></script>
		<script src="/js/google-maps.js" type="text/javascript" charset="utf-8"></script>
		<script src="/js/jquery.validate.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="/dialog/js/dialog.js" type="text/javascript" charset="utf-8"></script>
		<script src="/js/jquery.form.js"></script>
		<script src="/js/common.js"></script>
		<script src="/js/flatpickr.js" type="text/javascript" charset="utf-8"></script>
		<script src="/js/messages_zh.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="/js/shoufengqin.js"></script>
		<script src="/laydate/laydate.js"></script> <!-- 改成你的路径 -->

	</head>

	<body>
		<!--顶部导航 -->
        <nav class="topNavItemBox">
            <div id="ItemBox">
                <div class="title">智慧溯源系统</div>
                <div class="subtitle">肉品溯源管理</div>
                <div class="rightUserInfo">
                    <div class="commentAvatarDiv">
                        <img class="commentAvatarImage" src="/images/people.jpg">
                    </div>
                    <div class="userName">
					<#if Session.curEmployeeInfo??>
                        <a href="/admin/logout">${Session.curEmployeeInfo.emName}</a>
                    </#if>
                    </div>
                    <span class="glyphicon glyphicon-option-vertical userIcon" aria-hidden="true"></span>
                </div>
            </div>
        </nav>
		<div class="contain">
			<#include "leftPage.ftl">
		</div>
			<div id="middle1" class="page_main">
				<div id="middle2" class="page_content">
				<div class="add_title">
					<div class="second_title_main">新增生猪出场信息</div>
					<div class="second_title_main_bread">  生猪出场管理 > 新增生猪出场信息</div>
				</div>
                    <form id="addform" action="/admin/PigOut/addPigOut" method="post">
                        <ul><#if Session.curEmployeeInfo??>
                                <input type="hidden" name="operatorname" value="${Session.curEmployeeInfo.emName}"/>
                            </#if>

                            <li><label class="labelBeforinput">生猪编号</label><input name="purGid" id="purGid" class="bigInputtext" onblur="checkPig()" maxlength="9" required data-rule-isIntGtZero="true" type="text" /></li>
                            <li><label class="labelBeforinput">生猪重量</label><input name="outweight" class="bigInputtext" data-rule-isIntGtZero="true" required type="text" /></li>
                            <li><label class="labelBeforinput">重量单位</label><input name="weightunit" class="bigInputtext" id="inTime" required  /></li>
                            <li><label class="labelBeforinput">供货养殖场</label><select name="comGid" class="bigInputtext" required data-rule-notZero="true" class="bigInputtext" readonly type="text"><option value="0">请选择</option></select> </li>
                            <li><label class="labelBeforinput">接收人姓名</label><input name="receivername" class="bigInputtext" required  type="text" /></li>
                            <li><label class="labelBeforinput">接收人电话</label><input name="recievertel" class="bigInputtext"  type="text" data-rule-isTel="true"/></li>
                            <li><label class="labelBeforinput">接收屠宰场</label><select name="comGid2" class="bigInputtext" required data-rule-notZero="true"><option value="0">请选择</option></select></li>
                            <li><label class="labelBeforinput">交接地点</label><input name="place" class="bigInputtext" required type="text" /></li>
                            <li><label class="labelBeforinput">备注</label><input name="note" class="bigInputtext"  type="text" /></li>
                            <li><label class="labelBeforinput">出库日期</label><input name="outtime" id="test1" class="bigInputtext" id="outTime" required type="text" data-date-format="Y-m-d"/></li>
                            <li><input type="submit" value="确认" style="margin-left:50px;width: 100px;background-color: #00BFFF;" /></li>
                        </ul>
                    </form>
				
				</div>
			</div>
		</div>
		<div class="footer">
				<div class="footer_lineone">
					<span id="logo"></span>肉品溯源管理系统 
					<span class="footer_lineoneSpan"><a href="aboutus.html">关于我们</a></span>
					<span class="footer_lineoneSpan"><a target="_blank" href="http://www.cfsiw.com/">食品安全信息</a></span> 
					<span class="footer_lineoneSpan"><a href="suggestionAdd.ftl">联系我们</a></span>
				</div>
				<div class="footer_linetwo">
					 &copy;2017广东技术师范学院
				</div>
			</div>
	</body>
	<script type="text/javascript" charset="UTF-8">
		$(function() {
            //表单提交
            $("#addform").ajaxForm({
                success:function(data) {
                    var str = null;
                    var msg = null;
                    if(data == 1){
                        str = "success";
                        msg = "添加成功";
                        $.dialog({
                            type: 'info',
                            contentHtml: '<img class="info-icon" src="/dialog/images/icon/'+str+'.png" /><p class="info-text">'+msg+'</p>',
                            autoClose: 500
                        });
                        setTimeout('window.location.href="/admin/PigOut/findByCondition"',1000);
                    }else{
                        str = "fail";
                        msg = "添加失败";
                        $.dialog({
                            type: 'info',
                            contentHtml: '<img class="info-icon" src="/dialog/images/icon/'+str+'.png" /><p class="info-text">'+msg+'</p>',
                            autoClose: 1000
                        });
                    }

                }
            });

            //初始化侧边栏
            $(".vertical-nav").verticalnav({
                speed: 400,
                align: "left"
            });

            //企业下拉  接收屠宰场
            $.post("/admin/company/findCompanyByFeedType?typeID=1002", function(data) {
                console.log(data);
                for(var i = 0; i < data.length; i++) {
                    $("select[name='comGid2']").append("<option value='" + data[i].gid + "'>" + data[i].compname + "</option>");
                }
            });

            $.post("/admin/company/findCompanyByFeedType?typeID=1001", function(data) {
                console.log(data);
                for(var i = 0; i < data.length; i++) {
                    $("select[name='comGid']").append("<option value='" + data[i].gid + "'>" + data[i].compname + "</option>");
                }
            });

            //时间选择组件
            laydate.render({
                elem: '#test1' //指定元素
            });


            jQuery(document).ready(function ($) {
                $('.list22 ul li p').clickdown();
                $('.list-se p[class=title22]').clickup();
                $('.list22>ul>li').ad();
            });
        });


        //检验出场生猪是否有有出场检验
        function checkPig() {
            var pigID = $("#purGid").val();
            $.get("/admin/ProInspect/checkPur?pid="+pigID,function (data) {
                var str = null;
                var msg = null;
                if (data.msg == 1) {
                    str = "false";
                    msg = "该生猪编号不存在";
                    $.dialog({
                        type: 'info',
                        contentHtml: '<img class="info-icon" src="/dialog/images/icon/' + str + '.png" /><p class="info-text">' + msg + '</p>',
                        autoClose: 1000
                    });
                    $("#purGid").val("");
                } else if (data.msg == 2) {
                    str = "false";
                    msg = "该生猪未出场检验，不可出场";
                    $.dialog({
                        type: 'info',
                        contentHtml: '<img class="info-icon" src="/dialog/images/icon/' + str + '.png" /><p class="info-text">' + msg + '</p>',
                        autoClose: 1000
                    });
                    $("#purcid").val("");
                }
                else {
                    str = "success";
                    msg = "生猪信息合法";
                    $.dialog({
                        type: 'info',
                        contentHtml: '<img class="info-icon" src="/dialog/images/icon/' + str + '.png"  /><p class="info-text">' + msg + '</p>',
                        autoClose: 1000
                    });
                }
            });
        }

	</script>
</html>